#ifndef KTV_H
#define KTV_H

#include <QGraphicsObject>
#include <QGraphicsProxyWidget>
#include "gui.h"

class Query;
class MainMenu;
class AreaSlectionMenu;
class MiniMenu;
class SongMenu;
class MyItem;
class MyList;
class SingerList;
class SongList;
class SelectedSongList;
class TipList;
class Keyboard;
class InputField;
class MediaPlayer;
class QPropertyAnimation;
class KeyboardProxy;
class MediaPlayerProxy;

class KTV : public GUI
{
    Q_OBJECT
    Q_PROPERTY(QPointF keyboard_pos READ keyboardPos WRITE setKeyboardPos)
public:
    KTV(GUI *g, int w, int h);
    void launch();
    void exit();
    void setGuiUsable(bool u);
    void exchange();

    void requestSong(MyItem *song);
    void requestSinger(MyItem *singer);
    void nextSong();

    void setItemList(QList<MyItem *> *items);

    void selectMainMenu(int main_menu_index);
    void selectAreaSelectionMenu(int menu_index);
    void selectMiniMenu(int mini_menu_index);
    void selectSongMenu(int song_menu_index);

    void showMainMenu();
    void showAreaSelectionMenu();
    void showMiniMenu();
    void showSongMenu();
    void showSingerList();
    void showSongList();
    void showSelectedSongList();
    void showTipList();
    void showKeyboard();

    QPointF keyboardPos() { return p_keyboard_pos; }
    void setKeyboardPos(QPointF pos) { keyboardProxy->setPos(pos); }
    void setInputFieldText(QString t);

    void showMediaPlayer();
    void showCurrItem();

    void hideMiniMenu();
    void hideSongMenu();
    void hideKeyboard();

    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    void keyPressEvent(QKeyEvent *event);
private:
    void invisibleAllItems();
private:
    GUI *gui;
    int width;
    int height;
    QGraphicsItem *currItem;
    QGraphicsItem *prevItem;
    Query *query;

    MainMenu *mainMenu;
    AreaSlectionMenu *areaSlectionMenu;
    MiniMenu *miniMenu;
    SongMenu *songMenu;
    MyList *myList;
    SingerList *singerList;
    SongList *songList;
    SelectedSongList *selectedSongList;
    TipList *tipList;
    Keyboard *keyboard;
    QGraphicsProxyWidget *keyboardProxy;
    KeyboardProxy *kProxy;
    InputField *inputField;
    MediaPlayer *mediaPlayer;
    QGraphicsProxyWidget *mediaPlayerProxy;
    MediaPlayerProxy *mpProxy;

    QPointF p_keyboard_pos;
};

#endif // KTV_H
